@extends('default.layouts.master')

@section('title', '管理员管理')
@section('content-title', '管理员列表')

@section('content')

@section('screen-list')
@stop

@section('table-tr-th-list')
    <th class="text-center">Id</th>
    <th class="text-center">管理员名称</th>
    <th class="text-center hidden-sm hidden-xs hidden-md">邮箱</th>
    <th class="text-center hidden-sm">头像</th>
    <th class="text-center hidden-sm hidden-xs hidden-md"> 登录次数</th>
    <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间</th>
    <th class="text-center hidden-sm hidden-xs hidden-md"> 更新时间</th>
    <th class="text-center">状态</th>
    <th class="text-center">操作</th>
@stop

@section('tbody-tr-td-list')
    @if(count($list))
        @foreach($list['data'] as $item)
            <tr id="id_{{$item->admin_id}}" name="{{$item->admin_name}}">
                <td class="text-center"><a href="javascript:;"> {{$item->admin_id}} </a></td>
                <td class="text-center"> {{$item->admin_name}}</td>
                <td class="text-center hidden-sm hidden-xs hidden-md"> {{$item->admin_email}}</td>
                <td class="text-center hidden-sm">
                    @if($item->admin_head)
                        <img src="{{$item->admin_head}}"
                             onerror="imgerrorfun('{{ cnpscy_config('web_detault_show_img') }}');"/>
                    @endif
                </td>
                <td class="text-center hidden-sm hidden-xs hidden-md"> {{empty($item->admin_info) ? 0 : $item->admin_info->login_num}}
                </td>
                <td class="text-center hidden-sm hidden-xs hidden-md">
                    {{$item->admin_info ? date('Y-m-d H:i:s', $item->admin_info->created_time)
                    : ''}}
                </td>
                <td class="text-center hidden-sm hidden-xs hidden-md">
                    {{$item->admin_info ? date('Y-m-d H:i:s', $item->admin_info->updated_time)
                    : ''}}
                </td>
                <td class="text-center">
                    @if($item->admin_id != 1)
                        @if($item->is_check == 1)
                            <input type="checkbox" class="js-switch"
                                   onchange="changeFiledStatus(this, '{{ get_api_admin_url('changeFiledStatus') }}', {'admin_id' : '{{$item->admin_id}}', 'change_field' : 'is_check', 'change_value':0})"
                                   checked=""/>
                        @else
                            <input type="checkbox" class="js-switch"
                                   onchange="changeFiledStatus(this, '{{ get_api_admin_url('changeFiledStatus') }}', {'admin_id' : '{{$item->admin_id}}', 'change_field' : 'is_check', 'change_value':0})"
                                   checked=""/>
                        @endif
                    @else
                        <span class="btn btn-danger"> 禁止操作 </span>
                    @endif
                </td>
                <td class="text-center">
                    <button class="btn btn-xs btn-info" title="编辑“{{$item->admin_name}}”管理员"
                            onclick="hrefUrl('{{ get_web_admin_url('detail', ['id' => $item->admin_id]) }}')"><i
                                class="fa fa-pencil"></i>
                        编辑
                    </button>
                    @if($item->admin_id != 1)
                        <button class="btn btn-xs btn-danger" title="删除“{{$item->admin_name}}”管理员"
                                onclick="delOperation('{{$item->admin_id}}', '{{ get_web_admin_url('delete') }}')">
                            <i class="fa fa-times"></i> 删除
                        </button>
                    @endif
                </td>
            </tr>
        @endforeach
    @else
        <tr class="text-center">
            <td colspan="100"> 暂无数据！ </td>
        </tr>
    @endif
@stop

@include('default.layouts.master.index')
@stop

@section('script')
    <script type="text/javascript">
        window.onload = function () {
            closeLayerLoading(checkboxClass);
        }
    </script>
@stop
